﻿
/// ---------------------------------------------
/// 2012.7.24
/// 汪定新
///
/// ---------------------------------------------
//双击事件
function CustomDbClick() {
    var o = getPar(location.href, "RecruitmentPlanID");
    if (typeof (o) != "undefined") {
        parent.closeWin();
        return;
    }
    if (typeof (fnCustomEdit) == "function") {
        fnCustomEdit();
    }
}

//获取url里的参数值 name:参数名称
function getPar(source, name) {
    var reg = new RegExp("(^|\\?|&)" + name + "=([^&]*)(\\s|&|$)", "i");
    if (reg.test(source))
        return RegExp.$2;
    return "";
};

var dialog;
//----------------------------------------------
//添加
var fnCustomAdd = function () {
    var id = getPar(location.href, "id");
    document.getElementById("dialog1_h").innerHTML = "新增招聘计划明细";
    document.getElementById("EditUIWindow").src = "../Extend/YUIDataTableList.aspx?entity=V_hrRequirement&condition=RecruitmentPlanID='00000000-0000-0000-0000-000000000000' and auditStatus=2 &isShonwBtn=N&id=" + id + "&functionid=C64EBE01-F11C-4D98-8118-AD3A337D6911";
    SetDWH(750, 450, YAHOO.example.container.dialog1);
    YAHOO.example.container.dialog1.show();
    dialog = YAHOO.example.container.dialog1;
}

//删除第一步
var url = "";
var fnCustomDelete = function () {
    var list = this.mDataTable.getRecordSet()._records;
    var elist = [];
    for (var i = 0; i < list.length; i++) {
        if (list[i]._oData["iSun_Selected"] == true) {
            elist.push(list[i]._oData[const_entityID]);
        }
    }
    var RecruitmentPlanID = getPar(location.href, "id");
    if (elist.length == 0) {
        var recordID = myDataTable.getSelectedRows()[0];
        record = myDataTable.getRecord(recordID);
        if (record == null) {
            alert("请至少选择一条记录!");
            return;
        }
        var id = record.getData(const_entityID);
        url = "../EHR/hrRecruitmentAjax.aspx?flag=RecruitmentDetailSave&fun=del&id=" + id + "&RecruitmentPlanID=" + RecruitmentPlanID; //单条记录
    }
    else {
        var json = elist.join(",");
        url = "../EHR/hrRecruitmentAjax.aspx?flag=RecruitmentDetailSave&fun=del&json=" + json + "&RecruitmentPlanID=" + RecruitmentPlanID; //多条记录
    }
    YAHOO.example.container.dialog3.show();
    
}
//删除第二步
var fnCustomDeleteData = function () {
    YAHOO.util.Connect.asyncRequest('POST', url, {
        success: function (res) {
            try {
                var str = res.responseText;
                if (str == "0") {
                    alert("恭喜，删除成功!");
                    LoadData();
                }
                else {
                    alert("很遗憾，删除失败!");
                }
            }
            catch (e) {
            }
            finally {
            }
        },
        failure: function (error) {
            alert("数据错误：" + error.statusText);
        }
    }, null);
    YAHOO.example.container.dialog3.hide();
}